package org.wii.learner;
import org.wii.learner.ConsumedDB;
import android.app.Activity;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.*;


public class VegetableInput extends Activity {
    /** Called when the activity is first created. */
	
	private ConsumedDB database = new ConsumedDB(this);
    @Override
    public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState);
        setContentView(R.layout.vegetableinput);
        
     
     final EditText edtext = (EditText) findViewById(R.id.editText1);
       final TextView vtext = (TextView) findViewById(R.id.instrutext);
      vtext.setText("Enter the name of the vegetable:");
      final TextView vtext2 = (TextView) findViewById(R.id.instrutext2);
        vtext2.setText("Enter the number of servings of that vegetable:"); 
        
        Spinner spinner = (Spinner) findViewById(R.id.spinner1);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
                this, R.array.number_select, android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(adapter);
        
        spinner.setOnItemSelectedListener(new MyOnItemSelectedListener()); 

        final ViewFlipper flip=(ViewFlipper) findViewById(R.id.viewFlipper1);
        Button nextButton = (Button) findViewById(R.id.nextButton);
        nextButton.setOnClickListener(new OnClickListener()
        {

           public void onClick(View v) {
               flip.showNext();
           }

       });
        Button submit = (Button) findViewById(R.id.submitButton);
        submit.setOnClickListener (new MyOnSubmitListener(edtext, spinner, database)); 

   
        final TextView vtext3 = (TextView) findViewById(R.id.displayText);
        vtext3.setText("These are how many "+edtext.getText( ).toString( )+" servings you entered: "+ (String) spinner.getSelectedItem());
    
    }
    
    
}